<div class="page_head">
  <h2><%="Global Setting".t%></h2>
</div>
<%if flash[:notice]%>
 <div class='error_flash'><%=flash[:notice] / ("[" + @size.width.to_s + "px * " + @size.height.to_s + "px]")%></div>
<%end%>
<div class="setting">

  <h2><%="Account License".t%></h2>
  <div class='account_update'>
  <table class="data">
  <tr>
    <td class='title'><%="Account created at".t%>:</td><td class='entry'><%=@company.created_at.strftime("%Y-%m-%d")%></td>
    <td class='title'><%="Account Licence end at".t%>:</td><td class='entry'><%=@company.license_end_at%></td>
  </tr>
  <tr>
    <td class='title'><%="Your current plan".t%>:</td><td class='entry' colspan=3><%=@company.plan.name.t%></td>
  </tr>
  <tr>
    <td class='title'><%="Your plan detail".t%>:</td>
    <td class='entry' colspan=3>
       <table>
         <tr><td><%='Price'.t%>:</td><td><%=@company.plan.price_cn%><%='$/month'.t%></td></tr>
         <tr><td><%='Projects you can manage at once'.t%>:</td><td><%=@company.plan.projects%></td></tr>
         <tr><td><%='Max file can upload'.t%>:</td><td><%=number_to_human_size(@company.plan.max_size)%></td></tr>
         <tr><td><%='Storage for file sharing'.t%>:</td><td><%=number_to_human_size(@company.plan.storage_size)%></td></tr>
       </table>
    </td>
  </tr>
  <tr>
     <td class='title'><%="Payments History".t%></td>
     <td colspan=3>
       <table>
         <%@company.payments.each do |pay|%>
         <tr><td><%=pay.created_at.strftime("%Y-%m-%d")%>:</td><td><%=pay.amount%></td></tr>
         <%end%>
         <%if @company.payments.size == 0 %>
         <tr><td><%="No any payments".t%></td></tr>
         <%end%>
       </table>
     </td>
  </tr>
  </table>
  <hr class='black'>
  <%form_for :company,:url=>{:controller=>'global',:action=>'payments'} do |f|%>
   <div style="text-align:right">
   <%="Your current projects".t%>:<%=@company.active_projects.size%>
   <br/>
   <%="Total amount".t%>:<span id="total_payment"><%=@company.plan.price_cn%></span><%="$".t%>
     - 
   <%="Paid month".t%>:
    <select name=up_month id=up_month onchange="$('total_payment').innerHTML= (this.selectedIndex + 1) * $('plan_id').options[$('plan_id').selectedIndex].value.split('_')[1]">
    <%1.upto(24) do |m|%>
      <option value="<%=m%>"><%=m%></option>
    <%end%>
    </select>
     - 
    <%="Plan".t%>:
   <select name=plan_id  id=plan_id onchange="$('total_payment').innerHTML= $('up_month').options[$('up_month').selectedIndex].value * $('plan_id').options[$('plan_id').selectedIndex].value.split('_')[1]">
   <!--
   * $('plan_id').options[$('plan_id').selectedIndex].value.split("_")[1]">
   -->
   <%Plan.find(:all,:order=>"order_by").each do |p|%>
     <%if p.projects.to_i >= @company.active_projects.size or p.projects.to_i == 0%> 
     <option value="<%=p.id.to_s + "_" + p.price_cn.to_s%>" <%=p.id == @company.plan.id ? " selected":""%>><%=p.name.t%>(<%="Projects".t + " " + (p.projects.to_i == 0 ? "unlimited".t : p.projects.to_s) + " - " + p.price_cn.to_s + "$/month".t%>)</option>
     <%end%>
   <%end%>
   </select>
    <%=f.hidden_field :id,:value=>@company.id%></span>
    <%=submit_tag "Payment...".t,:disabled=>false%>
  <%end%>
   </div>
  </div>

  <h2><%="Your Logo".t%></h2>
  <%="Your logo appears on the login screen, the Dashboard, and the project home page.".t%> 
  <%="The logo must be in GIF,PNG,JPG format and can't be more than 200 pixels wide.".t%> 
  <%if File.exist?("#{RAILS_ROOT}/public/files/logos/#{@cur_user.company.id}/logo.gif")%>
  <div class=logo>
  <table>
    <tr>
     <td><%=image_tag("/files/logos/#{@cur_user.company.id}/logo.gif")%></td>
     <td><%=link_to"Delete this logo".t,{:action=>'delete_logo'},{:onclick=>"Element.show('indicator_del_logo')",:class=>'admin',:confirm=>"Are you sure?".t}%><%=indicator("del_logo")%></td>
    </tr>
  </table>
  </div>
  <%end%>
  <div class=logo_sub>
   <%form_for :logo,:url=>{:action=>'upload_logo'},:html=>{:multipart=>true} do%>
     <%=file_field_tag :file,:size=>60%><br/> 
     <%=indicator('sub_form')%>
     <%=submit_tag "Upload logo".t,:onclick=>"Element.show('indicator_sub_form')"%>
      <%="<span class=intro_txt>" + "and replace the current one".t + "</span>" if File.exist?("#{RAILS_ROOT}/public/files/logos/#{@cur_user.company.id}/logo.gif")%>
   <%end%>
  </div>
  <h2><%="Your trikr site name".t%></h2>
  <%="The trikr site name appears at the top of every page.".t%>
  <%form_for :company,:url=>{:action=>'update_name'} do |f|%>
  <div class=logo>
   <%=f.text_field"name"%>
  </div>  
  <hr class='black'>
  <%=submit_tag "Save Changes".t%>
  <%end%>

  <h2><%="Your site account owner".t%></h2>
  <%="Change the account owner of your site".t%>
  <%form_for :company,:url=>{:action=>'update_owner'} do |f|%>
  <div class=logo>
   <%=f.select :owner_id,@company.users.collect{|u| [u.name,u.id]}%>
  </div>  
  <hr class='black'>
  <%=submit_tag "Save Changes".t%>
  <%end%>
</div>
